﻿/****** Object:  Table [dbo].[Distributor]    Script Date: 11/19/2011 10:08:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Distributor](
	[user_id] [int] NOT NULL,
	[created] [datetime] NOT NULL,
	[alipay_account] [varchar](100) NOT NULL,
	[contact_person] [varchar](100) NOT NULL,
	[distributor_id] [varchar](50) NOT NULL,
	[distributor_name] [varchar](50) NOT NULL,
	[email] [varchar](50) NOT NULL,
	[mobile_phone] [varchar](30) NOT NULL,
	[phone] [varchar](30) NOT NULL,
	[shop_web_link] [varchar](100) NOT NULL,
 CONSTRAINT [PK_Distributor] PRIMARY KEY CLUSTERED 
(
	[distributor_id] ASC
) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Shop]    Script Date: 11/19/2011 10:08:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Shop](
	[ShopId] [smallint] IDENTITY(1,1) NOT NULL,
	[AppKey] [nvarchar](255) NULL,
	[AppSecret] [nvarchar](255) NULL,
	[Name] [nvarchar](255) NULL,
	[Updated] [datetime] NULL,
	[show] [tinyint] NULL,
	[status] [nvarchar](50) NULL,
	[SessionKey] [nvarchar](100) NULL,
 CONSTRAINT [PK__Shop__56B3DD81] PRIMARY KEY CLUSTERED 
(
	[ShopId] ASC
) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Log]    Script Date: 11/19/2011 10:08:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Log](
	[id] [bigint] IDENTITY(1,1) NOT NULL,
	[module] [nvarchar](50) NOT NULL,
	[message] [nvarchar](1500) NULL,
	[tracestack] [nvarchar](2000) NULL,
	[type] [nvarchar](50) NOT NULL,
	[created] [datetime] NOT NULL,
	[shopid] [smallint] NOT NULL,
 CONSTRAINT [PK_Logs] PRIMARY KEY CLUSTERED 
(
	[id] ASC
) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[OutSent]    Script Date: 11/19/2011 10:08:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OutSent](
	[OutSentId] [bigint] NOT NULL,
	[OutSid] [nvarchar](255) NULL,
	[Message] [nvarchar](255) NULL,
	[Memo] [text] NULL,
	[CompanyCode] [nvarchar](255) NULL,
	[Failure] [text] NULL,
	[ordertype] [nvarchar](50) NULL,
	[Success] [tinyint] NULL,
 CONSTRAINT [PK__OutSent__54CB950F] PRIMARY KEY CLUSTERED 
(
	[OutSentId] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[outsentnum]    Script Date: 11/19/2011 10:08:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[outsentnum](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[salepayid] [bigint] NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Sender]    Script Date: 11/19/2011 10:08:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Sender](
	[SenderID] [smallint] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](255) NULL,
	[AreaID] [nvarchar](255) NULL,
	[Address] [nvarchar](255) NULL,
	[Zip] [nvarchar](255) NULL,
	[Phone] [nvarchar](255) NULL,
	[Mobile] [nvarchar](255) NULL,
	[CompanyCode] [nvarchar](255) NULL,
PRIMARY KEY CLUSTERED 
(
	[SenderID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[OrderInfo]    Script Date: 11/19/2011 10:08:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OrderInfo](
	[OrderID] [bigint] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](255) NULL,
	[Price] [nvarchar](255) NULL,
	[Number] [decimal](19, 5) NULL,
	[OuterIId] [nvarchar](255) NULL,
	[Iid] [nvarchar](255) NULL,
	[SkuPropertiesName] [nvarchar](255) NULL,
	[ItemMealName] [nvarchar](255) NULL,
	[NumIid] [bigint] NULL,
	[SkuID] [nvarchar](255) NULL,
	[Trade] [bigint] NULL,
	[Discount_fee] [decimal](18, 2) NULL,
	[Adjust_fee] [decimal](18, 2) NULL,
	[payment] [decimal](18, 2) NULL,
	[status] [nvarchar](50) NULL,
	[refundID] [bigint] NULL,
	[Modified] [datetime] NULL,
	[shop] [smallint] NULL,
	[nb_dailidd] [tinyint] NULL,
	[id] [tinyint] NULL,
	[taobaooid] [bigint] NULL,
 CONSTRAINT [PK__OrderInfo__4F12BBB9] PRIMARY KEY CLUSTERED 
(
	[OrderID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Trade]    Script Date: 11/19/2011 10:08:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Trade](
	[Tid] [bigint] IDENTITY(1,1) NOT NULL,
	[Seller_nick] [nvarchar](255) NULL,
	[Buyer_nick] [nvarchar](255) NULL,
	[Status] [nvarchar](50) NULL,
	[OrdersTitle] [nvarchar](255) NULL,
	[OrderPrice] [nvarchar](50) NULL,
	[OrderNum] [smallint] NULL,
	[PayTime] [datetime] NULL,
	[AlipayNo] [nvarchar](255) NULL,
	[BuyerMemo] [ntext] NULL,
	[Payment] [nvarchar](50) NULL,
	[TaobaoTid] [bigint] NULL,
	[ReceiverAddress] [nvarchar](255) NULL,
	[ReceiverCity] [nvarchar](50) NULL,
	[ReceiverName] [nvarchar](50) NULL,
	[ReceiverState] [nvarchar](50) NULL,
	[ReceiverDistrict] [nvarchar](50) NULL,
	[ReceiverZip] [nvarchar](50) NULL,
	[ReceiverMobile] [nvarchar](50) NULL,
	[ReceiverPhone] [nvarchar](50) NULL,
	[SellerMobile] [nvarchar](50) NULL,
	[SellerName] [nvarchar](50) NULL,
	[Created] [datetime] NULL,
	[BuyerAlipayNo] [nvarchar](255) NULL,
	[PostFee] [nvarchar](50) NULL,
	[ShippingType] [nvarchar](50) NULL,
	[Type] [nvarchar](50) NULL,
	[Process] [smallint] NULL,
	[ProcessTime] [datetime] NULL,
	[Shop] [smallint] NULL,
	[makeUser] [nvarchar](50) NULL,
	[SellerMemo] [ntext] NULL,
	[SellerFlag] [nvarchar](50) NULL,
	[makesureflag] [tinyint] NULL,
	[gettkflag] [tinyint] NULL,
	[tkflag] [tinyint] NULL,
	[endtime] [datetime] NULL,
	[nb_dailidd] [tinyint] NULL,
	[Adjust_fee] [decimal](18, 2) NULL,
	[Discount_fee] [decimal](18, 2) NULL,
	[delflag] [tinyint] NULL,
	[cwchkflag] [tinyint] NULL,
	[cwchktime] [datetime] NULL,
	[cwchkUser] [nvarchar](50) NULL,
	[Seller_Flag] [smallint] NULL,
	[TProcess] [smallint] NULL,
	[intime] [datetime] NULL,
	[addwangwangflag] [tinyint] NULL,
 CONSTRAINT [PK__Trade__50FB042B] PRIMARY KEY CLUSTERED 
(
	[Tid] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[PromotionDetail]    Script Date: 11/19/2011 10:08:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PromotionDetail](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[PromotionDetailID] [bigint] NOT NULL,
	[Name] [nvarchar](500) NULL,
	[ShopID] [smallint] NOT NULL,
	[DiscountFee] [decimal](18, 2) NULL,
	[GiftItemName] [nvarchar](500) NULL,
	[TradeID] [bigint] NOT NULL,
 CONSTRAINT [PK_PromotionDetail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Refund]    Script Date: 11/19/2011 10:08:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Refund](
	[RefundID] [bigint] NULL,
	[TaobaoID] [bigint] NULL,
	[Created] [datetime] NULL,
	[Status] [ntext] NULL,
	[Modified] [datetime] NULL,
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[Shop] [smallint] NOT NULL,
	[readCflag] [int] NULL,
	[readSflag] [int] NULL,
	[Refundfee] [decimal](18, 2) NULL,
	[Totalfee] [decimal](18, 2) NULL,
	[Title] [ntext] NULL,
	[adminname] [nvarchar](250) NULL,
	[ddstatus] [nvarchar](50) NULL,
	[makesurepaytime] [datetime] NULL,
	[OuterID] [nvarchar](100) NULL,
	[ItemNumID] [bigint] NULL,
 CONSTRAINT [PK_Refund] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Default [DF_Shop_Updated]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Shop] ADD  CONSTRAINT [DF_Shop_Updated]  DEFAULT (1990 - 1 - 1) FOR [Updated]
GO
/****** Object:  Default [DF_Shop_show]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Shop] ADD  CONSTRAINT [DF_Shop_show]  DEFAULT (0) FOR [show]
GO
/****** Object:  Default [DF_OutSent_Success]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[OutSent] ADD  CONSTRAINT [DF_OutSent_Success]  DEFAULT (0) FOR [Success]
GO
/****** Object:  Default [DF_OrderInfo_shop]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[OrderInfo] ADD  CONSTRAINT [DF_OrderInfo_shop]  DEFAULT (0) FOR [shop]
GO
/****** Object:  Default [DF_OrderInfo_nb_dailidd]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[OrderInfo] ADD  CONSTRAINT [DF_OrderInfo_nb_dailidd]  DEFAULT (0) FOR [nb_dailidd]
GO
/****** Object:  Default [DF_Trade_Process]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Trade] ADD  CONSTRAINT [DF_Trade_Process]  DEFAULT (0) FOR [Process]
GO
/****** Object:  Default [DF_Trade_makesureflag]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Trade] ADD  CONSTRAINT [DF_Trade_makesureflag]  DEFAULT (0) FOR [makesureflag]
GO
/****** Object:  Default [DF_Trade_gettkflag]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Trade] ADD  CONSTRAINT [DF_Trade_gettkflag]  DEFAULT (0) FOR [gettkflag]
GO
/****** Object:  Default [DF_Trade_tkflag]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Trade] ADD  CONSTRAINT [DF_Trade_tkflag]  DEFAULT (0) FOR [tkflag]
GO
/****** Object:  Default [DF_Trade_dailidd]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Trade] ADD  CONSTRAINT [DF_Trade_dailidd]  DEFAULT (0) FOR [nb_dailidd]
GO
/****** Object:  Default [DF_Trade_delflag]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Trade] ADD  CONSTRAINT [DF_Trade_delflag]  DEFAULT (0) FOR [delflag]
GO
/****** Object:  Default [DF_Trade_cwchkflag]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Trade] ADD  CONSTRAINT [DF_Trade_cwchkflag]  DEFAULT (0) FOR [cwchkflag]
GO
/****** Object:  Default [DF_Trade_TProcess]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Trade] ADD  CONSTRAINT [DF_Trade_TProcess]  DEFAULT (0) FOR [TProcess]
GO
/****** Object:  Default [DF_Trade_intime]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Trade] ADD  CONSTRAINT [DF_Trade_intime]  DEFAULT (getdate()) FOR [intime]
GO
/****** Object:  Default [DF_Trade_addwangwangflag]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Trade] ADD  CONSTRAINT [DF_Trade_addwangwangflag]  DEFAULT (0) FOR [addwangwangflag]
GO
/****** Object:  Default [DF_Refund_readflag]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Refund] ADD  CONSTRAINT [DF_Refund_readflag]  DEFAULT (0) FOR [readCflag]
GO
/****** Object:  Default [DF_Refund_readSflag]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Refund] ADD  CONSTRAINT [DF_Refund_readSflag]  DEFAULT (0) FOR [readSflag]
GO
/****** Object:  Default [DF_Refund_ddstatus]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Refund] ADD  CONSTRAINT [DF_Refund_ddstatus]  DEFAULT (0) FOR [ddstatus]
GO
/****** Object:  ForeignKey [FK869CFA485A3FC5C4]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[OrderInfo]  WITH NOCHECK ADD  CONSTRAINT [FK869CFA485A3FC5C4] FOREIGN KEY([Trade])
REFERENCES [dbo].[Trade] ([Tid])
GO
ALTER TABLE [dbo].[OrderInfo] CHECK CONSTRAINT [FK869CFA485A3FC5C4]
GO
/****** Object:  ForeignKey [FKD485AD4A4805DB10]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Trade]  WITH NOCHECK ADD  CONSTRAINT [FKD485AD4A4805DB10] FOREIGN KEY([Shop])
REFERENCES [dbo].[Shop] ([ShopId])
GO
ALTER TABLE [dbo].[Trade] CHECK CONSTRAINT [FKD485AD4A4805DB10]
GO
/****** Object:  ForeignKey [FK_PromotionDetail_Shop]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[PromotionDetail]  WITH CHECK ADD  CONSTRAINT [FK_PromotionDetail_Shop] FOREIGN KEY([ShopID])
REFERENCES [dbo].[Shop] ([ShopId])
GO
ALTER TABLE [dbo].[PromotionDetail] CHECK CONSTRAINT [FK_PromotionDetail_Shop]
GO
/****** Object:  ForeignKey [FK_Refund_Shop]    Script Date: 11/19/2011 10:08:05 ******/
ALTER TABLE [dbo].[Refund]  WITH NOCHECK ADD  CONSTRAINT [FK_Refund_Shop] FOREIGN KEY([Shop])
REFERENCES [dbo].[Shop] ([ShopId])
GO
ALTER TABLE [dbo].[Refund] CHECK CONSTRAINT [FK_Refund_Shop]
GO
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Item](
	[id] [bigint] IDENTITY(1,1) NOT NULL,
	[detail_url] [nvarchar](500) NULL,
	[num_iid] [bigint] NOT NULL,
	[title] [nvarchar](500) NULL,
	[nick] [nvarchar](500) NULL,
	[type] [nvarchar](500) NULL,
	[desc] [ntext] NULL,
	[props_name] [nvarchar](500) NULL,
	[created] [datetime] NULL,
	[promoted_service] [nvarchar](500) NULL,
	[sub_stock] [int] NULL,
	[pic_url] [nvarchar](500) NULL,
	[num] [int] NULL,
	[valid_thru] [int] NULL,
	[list_time] [datetime] NULL,
	[delist_time] [datetime] NULL,
	[price] [decimal](18, 4) NULL,
	[post_fee] [decimal](18, 4) NULL,
	[express_fee] [decimal](18, 4) NULL,
	[ems_fee] [decimal](18, 4) NULL,
	[has_discount] [bit] NULL,
	[has_warranty] [bit] NULL,
	[has_showcase] [bit] NULL,
	[modified] [datetime] NULL,
	[shop] [smallint] NOT NULL,
	[outer_id] [nvarchar](100) NULL,
 CONSTRAINT [PK_Item] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO